precision mediump float;
uniform sampler2D uSampler;
varying vec2 vTextureCoord;
//uniform vec2 uTextureSize;
uniform vec2 blur;
//vec2 blur = vec2(5.0,5.0);
uniform vec2 iResolution;
//vec2 iResolution = vec2(1280.0,720.0);

//imgfile=map/6011.jpg
//param={"blur":{"x":5,"y":5},"r":3}
const int r = 1;
//uniform int r;

void main()
{
    // const int samples = r * 2 + 1;
    vec2 blurUv = blur / iResolution;
    vec4 color = vec4(0, 0, 0, 0);
    vec2 uv = vec2(0.0, 0.0);
    // blurUv /= float(r);

    int all = 0;
    for (int i = -r; i <= r; i++) {
        for (int j = -r; j <= r; j++) {
            uv.x = vTextureCoord.x + float(i) * blurUv.x;
            uv.y = vTextureCoord.y + float(j) * blurUv.y;
            color += texture2D(uSampler, uv);
            all++;
        }
    }

    color /= float(all);
    gl_FragColor = color;
}
